<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateKnowledgeTable extends Migration
{

    protected $tableName = 'knowledge';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->tableName, function (Blueprint $table) {
            $table->increments('id');
            $table->string('en_name')->comment('名称');
            $table->string('cn_name')->comment('中文');
            $table->string('audio')->comment('读音');
            $table->json('images')->comment('图片');
            $table->string('part_of_speech', 20)->default('')->comment('词性');
            $table->unsignedInteger('tag_id')->comment('标签');

            $table->timestamps();
            $table->softDeletes();

            $table->index(['en_name', 'part_of_speech']);
        });
        DB::statement("ALTER TABLE `$this->tableName` comment '知识点'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->tableName);
    }
}
